2 .\" Copyright (c) 2007, Sun Microsystems, Inc., All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH LDI_EV_NOTIFY 9F "Aug 21, 2007"
8 ldi_ev_notify \- propagate notification of a state change event
12 #include <sys/sunldi.h>
14 \fBint\fR \fBldi_ev_notify\fR(\fIdev_info_t *dip\fR, \fIminor_t minor\fR, \fIint spec_type\fR,
15 \fIldi_ev_cookie_t cookie\fR, \fIvoid *ev_data\fR);
21 Solaris DDI specific (Solaris DDI)
26 \fB\fIdev_info_t *dip\fR\fR
30 The \fBdevinfo\fR node of the layered consumer exporting the minor device.
36 \fB\fIminor_t minor\fR\fR
40 The minor number of the exported minor device.
46 \fB\fIint spec_type\fR\fR
50 The type of minor device (\fBS_IFCHR\fR or \fBS_IFBLK\fR).
56 \fB\fIldi_ev_cookie_t cookie\fR\fR
60 An opaque event cookie for the event type returned by a previous call to
61 \fBldi_ev_get_cookie\fR(9F).
67 \fB\fIvoid *ev_data\fR\fR
77 The \fBldi_ev_notify()\fR function propagates an event up the software stack.
78 It may result in two actions:
83 Invocation of \fBLDI\fR callback handlers registered by layered drivers up the
90 Device contract events generated on minors exported to \fBuserland\fR.
94 The event propagated up the software stack may be different than the event
95 received by the layered driver invoking \fBldi_ev_notify()\fR. For example, a
96 volume manager may receive an "offline" event on one of it's \fBLDI\fR opened
97 disks, but may choose to propagate a "degraded" event on minors it exports to
98 \fBuserland\fR (since it may have more than one copy of the data). The event
99 cookie argument to \fBldi_ev_notify()\fR may be different from the event cookie
100 currently possessed by the layered driver. If that is the case, the layered
101 driver must generate another event cookie via a new \fBldi_ev_get_cookie\fR(9F)
105 The\fBldi_ev_*\fR interfaces are designed to ensure that a "finalize" call is
106 generated for layered driver consumers at the earliest point where an
107 \fBLDI_EV_FAILURE\fR is detected. If this happens inside the \fBLDI\fR event
108 framework, then the framework will invoke finalize. In the event a layered
109 driver detects/generates an \fBLDI_EV_FAILURE\fR, then the layered driver must
110 invoke \fBldi_ev_finalize()\fR. The following is an example of a layered driver
111 invoking \fBldi_ev_finalize()\fR for the "foo" event:
116 widget_notify(ldi_handle_t lh, ldi_ev_cookie_t foo_cookie, void *arg,
120 ASSERT(strcmp(ldi_ev_get_type(foo_cookie), LDI_EV_FOO) == 0);
122 /* Map imported minors to exported minor */
123 widget_map(lh, &minor, &spec_type);
126 * Call ldi_ev_notify() to propagate events to our consumers.
127 * This *must* happen before we check if widget should block
130 if (ldi_ev_notify(dip, minor, spec_type, foo_cookie, ev_data)
132 return (LDI_EV_FAILURE);
135 * Next, check if we can allow the foo event
137 if (widget_release(lh, LDI_EV_FOO) == WIDGET_SUCCESS) {
138 return (LDI_EV_SUCCESS)
142 * We cannot permit the foo event. The first layer that detects
143 * failure i.e. us, must generate finalize events for *our*
146 ldi_ev_finalize(dip, minor, spec_type, LDI_EV_FAILURE,
147 foo_cookie, ev_data);
149 return (LDI_EV_FAILURE);
157 The return values for this function are:
161 \fB\fBLDI_EV_SUCCESS\fR\fR
165 Consumers up the software stack permit state change.
171 \fB\fBLDI_EV_FAILURE\fR\fR
175 Consumers are blocking the state change.
181 This function can be called from user and kernel context only.
185 \fBldi_ev_get_cookie\fR(9F), \fBldi_ev_register_callbacks\fR(9F),
186 \fBldi_ev_remove_callbacks\fR(9F)