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
5a3114836SGerry Liu * Common Development and Distribution License (the "License").
6a3114836SGerry Liu * 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 /*
227c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <assert.h>
277c478bd9Sstevel@tonic-gate #include <ctype.h>
287c478bd9Sstevel@tonic-gate #include <stdio.h>
297c478bd9Sstevel@tonic-gate #include <stdlib.h>
307c478bd9Sstevel@tonic-gate #include <string.h>
317c478bd9Sstevel@tonic-gate #include <unistd.h>
327c478bd9Sstevel@tonic-gate #include <macros.h>
337c478bd9Sstevel@tonic-gate #include <dirent.h>
347c478bd9Sstevel@tonic-gate #include <libgen.h>
357c478bd9Sstevel@tonic-gate #include <libdevinfo.h>
367c478bd9Sstevel@tonic-gate #define CFGA_PLUGIN_LIB
377c478bd9Sstevel@tonic-gate #include <config_admin.h>
387c478bd9Sstevel@tonic-gate #include "ap.h"
397c478bd9Sstevel@tonic-gate
40a3114836SGerry Liu #ifdef __x86
41a3114836SGerry Liu #include <libscf_priv.h>
42a3114836SGerry Liu
43a3114836SGerry Liu static int fastreboot_disabled;
44a3114836SGerry Liu #endif /* __x86 */
45a3114836SGerry Liu
467c478bd9Sstevel@tonic-gate static cfga_err_t
ap_suspend_check(apd_t * a,int cmd,int first,int last,int * suspend)477c478bd9Sstevel@tonic-gate ap_suspend_check(apd_t *a, int cmd, int first, int last, int *suspend)
487c478bd9Sstevel@tonic-gate {
497c478bd9Sstevel@tonic-gate int c;
507c478bd9Sstevel@tonic-gate int rc;
517c478bd9Sstevel@tonic-gate int skip;
527c478bd9Sstevel@tonic-gate int check;
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate skip = a->opts.skip;
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate * Check if any of the steps in the sequence
587c478bd9Sstevel@tonic-gate * may require a suspension of service and ask
597c478bd9Sstevel@tonic-gate * the user to confirm.
607c478bd9Sstevel@tonic-gate */
617c478bd9Sstevel@tonic-gate for (check = 0, c = first; c <= last; c++)
627c478bd9Sstevel@tonic-gate if (mask(c) & skip)
637c478bd9Sstevel@tonic-gate continue;
647c478bd9Sstevel@tonic-gate else if ((rc = ap_suspend_query(a, c, &check)) != CFGA_OK)
657c478bd9Sstevel@tonic-gate return (rc);
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate *suspend = check;
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate * If a suspend is required, ask for user confirmation.
717c478bd9Sstevel@tonic-gate * The force flag overrides the user confirmation.
727c478bd9Sstevel@tonic-gate */
737c478bd9Sstevel@tonic-gate if (check && (!ap_getopt(a, OPT_FORCE)) && (!ap_confirm(a))) {
747c478bd9Sstevel@tonic-gate ap_err(a, ERR_CMD_NACK, cmd);
757c478bd9Sstevel@tonic-gate return (CFGA_NACK);
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate return (CFGA_OK);
797c478bd9Sstevel@tonic-gate }
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate #define AP_SEQ_OK 0
827c478bd9Sstevel@tonic-gate #define AP_SEQ_NULL 1
837c478bd9Sstevel@tonic-gate #define AP_SEQ_FAIL -1
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate * Sequence a cfgadm state change command into driver commands.
877c478bd9Sstevel@tonic-gate * The rstate and ostate of the AP are needed at this point
887c478bd9Sstevel@tonic-gate * in order to compute the proper sequence.
897c478bd9Sstevel@tonic-gate */
907c478bd9Sstevel@tonic-gate static int
ap_seq_get(apd_t * a,int cmd,int * first,int * last)917c478bd9Sstevel@tonic-gate ap_seq_get(apd_t *a, int cmd, int *first, int *last)
927c478bd9Sstevel@tonic-gate {
937c478bd9Sstevel@tonic-gate int done = 0;
947c478bd9Sstevel@tonic-gate int f = CMD_NONE;
957c478bd9Sstevel@tonic-gate int l = CMD_NONE;
967c478bd9Sstevel@tonic-gate cfga_stat_t rs, os;
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gate ap_state(a, &rs, &os);
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate switch (rs) {
1017c478bd9Sstevel@tonic-gate case CFGA_STAT_EMPTY:
1027c478bd9Sstevel@tonic-gate switch (os) {
1037c478bd9Sstevel@tonic-gate case CFGA_STAT_UNCONFIGURED:
1047c478bd9Sstevel@tonic-gate switch (cmd) {
1057c478bd9Sstevel@tonic-gate case CMD_UNCONFIGURE:
1067c478bd9Sstevel@tonic-gate done++;
1077c478bd9Sstevel@tonic-gate break;
1087c478bd9Sstevel@tonic-gate default:
1097c478bd9Sstevel@tonic-gate break;
1107c478bd9Sstevel@tonic-gate }
1117c478bd9Sstevel@tonic-gate break;
1127c478bd9Sstevel@tonic-gate default:
1137c478bd9Sstevel@tonic-gate break;
1147c478bd9Sstevel@tonic-gate }
1157c478bd9Sstevel@tonic-gate break;
1167c478bd9Sstevel@tonic-gate case CFGA_STAT_DISCONNECTED:
1177c478bd9Sstevel@tonic-gate switch (os) {
1187c478bd9Sstevel@tonic-gate case CFGA_STAT_UNCONFIGURED:
1197c478bd9Sstevel@tonic-gate switch (cmd) {
1207c478bd9Sstevel@tonic-gate case CMD_DISCONNECT:
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate * skip the disconnect command since
1237c478bd9Sstevel@tonic-gate * the rstate is already disconnected
1247c478bd9Sstevel@tonic-gate */
1257c478bd9Sstevel@tonic-gate f = CMD_DISCONNECT;
1267c478bd9Sstevel@tonic-gate a->opts.skip |= mask(CMD_DISCONNECT);
1277c478bd9Sstevel@tonic-gate l = CMD_UNASSIGN;
1287c478bd9Sstevel@tonic-gate break;
1297c478bd9Sstevel@tonic-gate case CMD_UNCONFIGURE:
1307c478bd9Sstevel@tonic-gate done++;
1317c478bd9Sstevel@tonic-gate break;
1327c478bd9Sstevel@tonic-gate case CMD_CONNECT:
1337c478bd9Sstevel@tonic-gate f = CMD_ASSIGN;
1347c478bd9Sstevel@tonic-gate l = CMD_CONNECT;
1357c478bd9Sstevel@tonic-gate break;
1367c478bd9Sstevel@tonic-gate case CMD_CONFIGURE:
1377c478bd9Sstevel@tonic-gate f = CMD_ASSIGN;
1387c478bd9Sstevel@tonic-gate l = CMD_RCM_CAP_ADD;
1397c478bd9Sstevel@tonic-gate break;
1407c478bd9Sstevel@tonic-gate default:
1417c478bd9Sstevel@tonic-gate break;
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate break;
1447c478bd9Sstevel@tonic-gate default:
1457c478bd9Sstevel@tonic-gate break;
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate break;
1487c478bd9Sstevel@tonic-gate case CFGA_STAT_CONNECTED:
1497c478bd9Sstevel@tonic-gate switch (os) {
1507c478bd9Sstevel@tonic-gate case CFGA_STAT_UNCONFIGURED:
1517c478bd9Sstevel@tonic-gate switch (cmd) {
1527c478bd9Sstevel@tonic-gate case CMD_CONNECT:
1537c478bd9Sstevel@tonic-gate case CMD_UNCONFIGURE:
1547c478bd9Sstevel@tonic-gate done++;
1557c478bd9Sstevel@tonic-gate break;
1567c478bd9Sstevel@tonic-gate case CMD_DISCONNECT:
1577c478bd9Sstevel@tonic-gate f = CMD_DISCONNECT;
1587c478bd9Sstevel@tonic-gate l = CMD_UNASSIGN;
1597c478bd9Sstevel@tonic-gate break;
1607c478bd9Sstevel@tonic-gate case CMD_CONFIGURE:
1617c478bd9Sstevel@tonic-gate f = CMD_CONFIGURE;
1627c478bd9Sstevel@tonic-gate l = CMD_RCM_CAP_ADD;
1637c478bd9Sstevel@tonic-gate break;
1647c478bd9Sstevel@tonic-gate default:
1657c478bd9Sstevel@tonic-gate break;
1667c478bd9Sstevel@tonic-gate }
1677c478bd9Sstevel@tonic-gate break;
1687c478bd9Sstevel@tonic-gate case CFGA_STAT_CONFIGURED:
1697c478bd9Sstevel@tonic-gate switch (cmd) {
1707c478bd9Sstevel@tonic-gate case CMD_CONNECT:
1717c478bd9Sstevel@tonic-gate done++;
1727c478bd9Sstevel@tonic-gate break;
1737c478bd9Sstevel@tonic-gate case CMD_DISCONNECT:
1747c478bd9Sstevel@tonic-gate f = CMD_SUSPEND_CHECK;
1757c478bd9Sstevel@tonic-gate l = CMD_UNASSIGN;
1767c478bd9Sstevel@tonic-gate break;
1777c478bd9Sstevel@tonic-gate case CMD_CONFIGURE:
1787c478bd9Sstevel@tonic-gate f = CMD_CONFIGURE;
1797c478bd9Sstevel@tonic-gate l = CMD_RCM_CAP_ADD;
1807c478bd9Sstevel@tonic-gate break;
1817c478bd9Sstevel@tonic-gate case CMD_UNCONFIGURE:
1827c478bd9Sstevel@tonic-gate f = CMD_SUSPEND_CHECK;
1837c478bd9Sstevel@tonic-gate l = CMD_RCM_CAP_NOTIFY;
1847c478bd9Sstevel@tonic-gate break;
1857c478bd9Sstevel@tonic-gate default:
1867c478bd9Sstevel@tonic-gate break;
1877c478bd9Sstevel@tonic-gate }
1887c478bd9Sstevel@tonic-gate break;
1897c478bd9Sstevel@tonic-gate default:
1907c478bd9Sstevel@tonic-gate break;
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate break;
1937c478bd9Sstevel@tonic-gate default:
1947c478bd9Sstevel@tonic-gate break;
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate if (f == CMD_NONE) {
1987c478bd9Sstevel@tonic-gate if (done)
1997c478bd9Sstevel@tonic-gate return (AP_SEQ_NULL);
2007c478bd9Sstevel@tonic-gate ap_err(a, ERR_TRANS_INVAL, cmd);
2017c478bd9Sstevel@tonic-gate return (AP_SEQ_FAIL);
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate *first = f;
2057c478bd9Sstevel@tonic-gate *last = l;
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate DBG("ap_seq(%d, %d, %d, %p, %p) = (%d, %d)\n",
208a3114836SGerry Liu rs, os, cmd, (void *)first, (void *)last, f, l);
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate return (AP_SEQ_OK);
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate
2137c478bd9Sstevel@tonic-gate #define DBG_RECOVER_MSG(f, l) \
2147c478bd9Sstevel@tonic-gate DBG("Sequencing recovery: first = %s, last = %s\n", \
2157c478bd9Sstevel@tonic-gate ap_cmd_name(f), ap_cmd_name(l))
2167c478bd9Sstevel@tonic-gate
2177c478bd9Sstevel@tonic-gate cfga_err_t
ap_seq_exec(apd_t * a,int cmd,int first,int last)2187c478bd9Sstevel@tonic-gate ap_seq_exec(apd_t *a, int cmd, int first, int last)
2197c478bd9Sstevel@tonic-gate {
2207c478bd9Sstevel@tonic-gate int c;
2217c478bd9Sstevel@tonic-gate int skip;
2227c478bd9Sstevel@tonic-gate int suspend;
2237c478bd9Sstevel@tonic-gate int resume;
2247c478bd9Sstevel@tonic-gate cfga_err_t rc;
2257c478bd9Sstevel@tonic-gate int recover_f = CMD_NONE; /* first recovery cmd */
2267c478bd9Sstevel@tonic-gate int recover_l = CMD_NONE; /* last recovery cmd */
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate
2297c478bd9Sstevel@tonic-gate suspend = 0;
2307c478bd9Sstevel@tonic-gate resume = 0;
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate skip = a->opts.skip;
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate * The unassign step is skipped unless explicity requested
2367c478bd9Sstevel@tonic-gate * either by a -x request or as an option to a disconnect
2377c478bd9Sstevel@tonic-gate * request.
2387c478bd9Sstevel@tonic-gate */
2397c478bd9Sstevel@tonic-gate if (cmd != CMD_UNASSIGN && ap_getopt(a, OPT_UNASSIGN) == 0)
2407c478bd9Sstevel@tonic-gate skip |= mask(CMD_UNASSIGN);
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate * Check for platform options
2447c478bd9Sstevel@tonic-gate */
2457c478bd9Sstevel@tonic-gate rc = ap_platopts_check(a, first, last);
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate if (rc != CFGA_OK) {
2487c478bd9Sstevel@tonic-gate goto done;
2497c478bd9Sstevel@tonic-gate }
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate for (c = first; c <= last; c++) {
2527c478bd9Sstevel@tonic-gate if (mask(c) & skip) {
2537c478bd9Sstevel@tonic-gate ap_msg(a, MSG_SKIP, c, a->target);
2547c478bd9Sstevel@tonic-gate continue;
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate
2577c478bd9Sstevel@tonic-gate DBG("exec %s\n", ap_cmd_name(c));
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate /*
2607c478bd9Sstevel@tonic-gate * If the suspend operation does not
2617c478bd9Sstevel@tonic-gate * succeed, resume any devices already
2627c478bd9Sstevel@tonic-gate * suspended as well as the device on
2637c478bd9Sstevel@tonic-gate * which the operation failed.
2647c478bd9Sstevel@tonic-gate */
2657c478bd9Sstevel@tonic-gate switch (c) {
2667c478bd9Sstevel@tonic-gate case CMD_SUSPEND_CHECK:
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate * Check whether the user allows a suspend
2697c478bd9Sstevel@tonic-gate * operation if the suspend is required.
2707c478bd9Sstevel@tonic-gate * Next step is to allow RCM clients to
2717c478bd9Sstevel@tonic-gate * interpose on the suspend operation.
2727c478bd9Sstevel@tonic-gate */
2737c478bd9Sstevel@tonic-gate rc = ap_suspend_check(a, cmd,
274a3114836SGerry Liu first + 1, last, &suspend);
2757c478bd9Sstevel@tonic-gate break;
2767c478bd9Sstevel@tonic-gate case CMD_RCM_SUSPEND:
2777c478bd9Sstevel@tonic-gate if (suspend && ((rc = ap_rcm_ctl(a, c)) == CFGA_OK)) {
2787c478bd9Sstevel@tonic-gate /*
2797c478bd9Sstevel@tonic-gate * Mark the fact that a suspend operation
2807c478bd9Sstevel@tonic-gate * is required, and that RCM clients have
2817c478bd9Sstevel@tonic-gate * allowed the suspend.
2827c478bd9Sstevel@tonic-gate */
2837c478bd9Sstevel@tonic-gate ap_setopt(a, OPT_SUSPEND_OK);
2847c478bd9Sstevel@tonic-gate resume++;
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate break;
2877c478bd9Sstevel@tonic-gate case CMD_RCM_RESUME:
2887c478bd9Sstevel@tonic-gate if (resume) {
2897c478bd9Sstevel@tonic-gate (void) ap_rcm_ctl(a, c);
2907c478bd9Sstevel@tonic-gate resume--;
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate break;
2937c478bd9Sstevel@tonic-gate case CMD_RCM_OFFLINE:
2947c478bd9Sstevel@tonic-gate case CMD_RCM_CAP_DEL:
2957c478bd9Sstevel@tonic-gate rc = ap_rcm_ctl(a, c);
2967c478bd9Sstevel@tonic-gate break;
2977c478bd9Sstevel@tonic-gate case CMD_RCM_ONLINE:
2987c478bd9Sstevel@tonic-gate case CMD_RCM_CAP_ADD:
2997c478bd9Sstevel@tonic-gate case CMD_RCM_REMOVE:
3007c478bd9Sstevel@tonic-gate case CMD_RCM_CAP_NOTIFY:
3017c478bd9Sstevel@tonic-gate (void) ap_rcm_ctl(a, c);
3027c478bd9Sstevel@tonic-gate break;
303a3114836SGerry Liu
304a3114836SGerry Liu #ifdef __x86
305a3114836SGerry Liu /*
306a3114836SGerry Liu * Disable fast reboot if a CPU/MEM/IOH hotplug event happens.
307a3114836SGerry Liu * Note: this is a temporary solution and will be revised when
308a3114836SGerry Liu * fast reboot can support CPU/MEM/IOH DR operations in the
309a3114836SGerry Liu * future.
310a3114836SGerry Liu *
311a3114836SGerry Liu * ACPI BIOS generates some static ACPI tables, such as MADT,
312a3114836SGerry Liu * SRAT and SLIT, to describe the system hardware configuration
313a3114836SGerry Liu * on power-on. When a CPU/MEM/IOH hotplug event happens, those
314a3114836SGerry Liu * static tables won't be updated and will become stale.
315a3114836SGerry Liu *
316a3114836SGerry Liu * If we reset the system by fast reboot, BIOS will have no
317a3114836SGerry Liu * chance to regenerate those staled static tables. Fast reboot
318a3114836SGerry Liu * can't tolerate such inconsistency between staled ACPI tables
319a3114836SGerry Liu * and real hardware configuration yet.
320a3114836SGerry Liu *
321a3114836SGerry Liu * A temporary solution is introduced to disable fast reboot if
322a3114836SGerry Liu * CPU/MEM/IOH hotplug event happens. This solution should be
323a3114836SGerry Liu * revised when fast reboot is enhanced to support CPU/MEM/IOH
324a3114836SGerry Liu * DR operations.
325a3114836SGerry Liu */
326a3114836SGerry Liu case CMD_ASSIGN:
327a3114836SGerry Liu case CMD_POWERON:
328a3114836SGerry Liu case CMD_POWEROFF:
329a3114836SGerry Liu case CMD_UNASSIGN:
330a3114836SGerry Liu if (!fastreboot_disabled &&
331a3114836SGerry Liu scf_fastreboot_default_set_transient(B_FALSE) ==
332a3114836SGerry Liu SCF_SUCCESS) {
333a3114836SGerry Liu fastreboot_disabled = 1;
334a3114836SGerry Liu }
335a3114836SGerry Liu #endif /* __x86 */
336*2411ecfcSToomas Soome /* FALLTHROUGH */
337a3114836SGerry Liu
3387c478bd9Sstevel@tonic-gate default:
3397c478bd9Sstevel@tonic-gate rc = ap_ioctl(a, c);
3407c478bd9Sstevel@tonic-gate break;
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate
3437c478bd9Sstevel@tonic-gate if (rc != CFGA_OK)
3447c478bd9Sstevel@tonic-gate break;
3457c478bd9Sstevel@tonic-gate
3467c478bd9Sstevel@tonic-gate }
3477c478bd9Sstevel@tonic-gate done:
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate if (resume)
3507c478bd9Sstevel@tonic-gate (void) ap_rcm_ctl(a, CMD_RCM_RESUME);
3517c478bd9Sstevel@tonic-gate
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate * Check if any operations failed. If so, attempt to rollback
3547c478bd9Sstevel@tonic-gate * to previously known states.
3557c478bd9Sstevel@tonic-gate * Note: The rollback is currently limited to RCM operations.
3567c478bd9Sstevel@tonic-gate */
3577c478bd9Sstevel@tonic-gate if (rc != CFGA_OK) {
3587c478bd9Sstevel@tonic-gate if (c == CMD_UNCONFIGURE ||
3597c478bd9Sstevel@tonic-gate c == CMD_RCM_OFFLINE ||
3607c478bd9Sstevel@tonic-gate c == CMD_RCM_CAP_DEL) {
3617c478bd9Sstevel@tonic-gate DBG("ap_seq_exec: %s failed\n", ap_cmd_name(c));
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate switch (c) {
3647c478bd9Sstevel@tonic-gate case CMD_UNCONFIGURE:
3657c478bd9Sstevel@tonic-gate /*
3667c478bd9Sstevel@tonic-gate * If the unconfigure operation fails, perform
3677c478bd9Sstevel@tonic-gate * an RCM_ONLINE and RCM_CAP_NOTIFY only. This
3687c478bd9Sstevel@tonic-gate * keeps RCM clients consistent with the domain.
3697c478bd9Sstevel@tonic-gate */
3707c478bd9Sstevel@tonic-gate recover_f = CMD_RCM_ONLINE;
3717c478bd9Sstevel@tonic-gate recover_l = CMD_RCM_ONLINE;
3727c478bd9Sstevel@tonic-gate DBG_RECOVER_MSG(recover_f, recover_l);
3737c478bd9Sstevel@tonic-gate (void) ap_seq_exec(a, cmd, recover_f,
3747c478bd9Sstevel@tonic-gate recover_l);
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gate recover_f = CMD_RCM_CAP_NOTIFY;
3777c478bd9Sstevel@tonic-gate recover_l = CMD_RCM_CAP_NOTIFY;
3787c478bd9Sstevel@tonic-gate DBG_RECOVER_MSG(recover_f, recover_l);
3797c478bd9Sstevel@tonic-gate (void) ap_seq_exec(a, cmd, recover_f,
3807c478bd9Sstevel@tonic-gate recover_l);
3817c478bd9Sstevel@tonic-gate break;
3827c478bd9Sstevel@tonic-gate case CMD_RCM_OFFLINE:
3837c478bd9Sstevel@tonic-gate recover_f = CMD_RCM_ONLINE;
3847c478bd9Sstevel@tonic-gate recover_l = CMD_RCM_CAP_ADD;
3857c478bd9Sstevel@tonic-gate DBG_RECOVER_MSG(recover_f, recover_l);
3867c478bd9Sstevel@tonic-gate (void) ap_seq_exec(a, cmd, recover_f,
3877c478bd9Sstevel@tonic-gate recover_l);
3887c478bd9Sstevel@tonic-gate break;
3897c478bd9Sstevel@tonic-gate case CMD_RCM_CAP_DEL:
3907c478bd9Sstevel@tonic-gate recover_f = CMD_RCM_CAP_ADD;
3917c478bd9Sstevel@tonic-gate recover_l = CMD_RCM_CAP_ADD;
3927c478bd9Sstevel@tonic-gate DBG_RECOVER_MSG(recover_f, recover_l);
3937c478bd9Sstevel@tonic-gate (void) ap_seq_exec(a, cmd, recover_f,
3947c478bd9Sstevel@tonic-gate recover_l);
3957c478bd9Sstevel@tonic-gate break;
3967c478bd9Sstevel@tonic-gate default:
3977c478bd9Sstevel@tonic-gate break;
3987c478bd9Sstevel@tonic-gate }
3997c478bd9Sstevel@tonic-gate
4007c478bd9Sstevel@tonic-gate DBG("recovery complete!\n");
4017c478bd9Sstevel@tonic-gate }
4027c478bd9Sstevel@tonic-gate }
4037c478bd9Sstevel@tonic-gate return (rc);
4047c478bd9Sstevel@tonic-gate }
4057c478bd9Sstevel@tonic-gate
4067c478bd9Sstevel@tonic-gate cfga_err_t
ap_cmd_exec(apd_t * a,int cmd)4077c478bd9Sstevel@tonic-gate ap_cmd_exec(apd_t *a, int cmd)
4087c478bd9Sstevel@tonic-gate {
4097c478bd9Sstevel@tonic-gate return (ap_seq_exec(a, cmd, cmd, cmd));
4107c478bd9Sstevel@tonic-gate }
4117c478bd9Sstevel@tonic-gate
4127c478bd9Sstevel@tonic-gate cfga_err_t
ap_cmd_seq(apd_t * a,int cmd)4137c478bd9Sstevel@tonic-gate ap_cmd_seq(apd_t *a, int cmd)
4147c478bd9Sstevel@tonic-gate {
4157c478bd9Sstevel@tonic-gate int first, last;
4167c478bd9Sstevel@tonic-gate cfga_err_t rc;
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate switch (ap_seq_get(a, cmd, &first, &last)) {
4197c478bd9Sstevel@tonic-gate case AP_SEQ_OK:
4207c478bd9Sstevel@tonic-gate rc = ap_seq_exec(a, cmd, first, last);
4217c478bd9Sstevel@tonic-gate break;
4227c478bd9Sstevel@tonic-gate case AP_SEQ_NULL:
4237c478bd9Sstevel@tonic-gate rc = CFGA_OK;
4247c478bd9Sstevel@tonic-gate break;
4257c478bd9Sstevel@tonic-gate case AP_SEQ_FAIL:
4267c478bd9Sstevel@tonic-gate default:
4277c478bd9Sstevel@tonic-gate rc = CFGA_LIB_ERROR;
4287c478bd9Sstevel@tonic-gate break;
4297c478bd9Sstevel@tonic-gate }
4307c478bd9Sstevel@tonic-gate
4317c478bd9Sstevel@tonic-gate return (rc);
4327c478bd9Sstevel@tonic-gate }
433