xref: /onnv-gate/usr/src/uts/common/avs/ns/nsctl/nsc_trap.c (revision 9093:cd587b0bd19c)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
22*9093SRamana.Srikanth@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237836SJohn.Forte@Sun.COM  * Use is subject to license terms.
247836SJohn.Forte@Sun.COM  */
257836SJohn.Forte@Sun.COM 
267836SJohn.Forte@Sun.COM #include <sys/ddi.h>
277836SJohn.Forte@Sun.COM #include <sys/sunddi.h>
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM #ifdef DS_DDICT
307836SJohn.Forte@Sun.COM #include "../contract.h"
317836SJohn.Forte@Sun.COM #endif
327836SJohn.Forte@Sun.COM 
337836SJohn.Forte@Sun.COM #define	SVE_STE_CLASS	"SVE_STE"
347836SJohn.Forte@Sun.COM #define	SVE_II_CLASS	"SVE_II"
357836SJohn.Forte@Sun.COM #define	SVE_CACHE_CLASS	"SVE_CACHE"
367836SJohn.Forte@Sun.COM 
377836SJohn.Forte@Sun.COM void
nsc_do_sysevent(char * driver_name,char * trap_messages,int errorno,int alertlevel,char * component,dev_info_t * info_dip)387836SJohn.Forte@Sun.COM nsc_do_sysevent(char *driver_name, char *trap_messages, int errorno,
397836SJohn.Forte@Sun.COM 	int alertlevel, char *component, dev_info_t *info_dip)
407836SJohn.Forte@Sun.COM {
417836SJohn.Forte@Sun.COM #if !defined(DS_DDICT) && !defined(_SunOS_5_6) && \
427836SJohn.Forte@Sun.COM 	!defined(_SunOS_5_7) && !defined(_SunOS_5_8)
437836SJohn.Forte@Sun.COM 
447836SJohn.Forte@Sun.COM 	nvlist_t *attr_list;
457836SJohn.Forte@Sun.COM 	int rc;
467836SJohn.Forte@Sun.COM 
477836SJohn.Forte@Sun.COM 	attr_list = NULL;
487836SJohn.Forte@Sun.COM 	rc = nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE, KM_SLEEP);
497836SJohn.Forte@Sun.COM 	if (rc != 0) {
507836SJohn.Forte@Sun.COM 		goto out;
517836SJohn.Forte@Sun.COM 	}
527836SJohn.Forte@Sun.COM 	rc = nvlist_add_int32(attr_list, "alertlevel", alertlevel);
537836SJohn.Forte@Sun.COM 	if (rc != 0) {
547836SJohn.Forte@Sun.COM 		goto out;
557836SJohn.Forte@Sun.COM 	}
56*9093SRamana.Srikanth@Sun.COM 	rc = nvlist_add_string(attr_list, "messagevalue", trap_messages);
577836SJohn.Forte@Sun.COM 	if (rc != 0) {
587836SJohn.Forte@Sun.COM 		goto out;
597836SJohn.Forte@Sun.COM 	}
607836SJohn.Forte@Sun.COM 	rc = nvlist_add_int32(attr_list, "errorno", errorno);
617836SJohn.Forte@Sun.COM 	if (rc != 0) {
627836SJohn.Forte@Sun.COM 		goto out;
637836SJohn.Forte@Sun.COM 	}
647836SJohn.Forte@Sun.COM 	if (strcmp(driver_name, "sdbc") == 0)
657836SJohn.Forte@Sun.COM 		rc = ddi_log_sysevent(info_dip, DDI_VENDOR_SUNW,
66*9093SRamana.Srikanth@Sun.COM 		    SVE_CACHE_CLASS, component, attr_list, NULL, DDI_SLEEP);
677836SJohn.Forte@Sun.COM 	else if (strcmp(driver_name, "ste") == 0)
687836SJohn.Forte@Sun.COM 		rc = ddi_log_sysevent(info_dip, DDI_VENDOR_SUNW,
69*9093SRamana.Srikanth@Sun.COM 		    SVE_STE_CLASS, component, attr_list, NULL, DDI_SLEEP);
707836SJohn.Forte@Sun.COM 	else if (strcmp(driver_name, "ii") == 0)
717836SJohn.Forte@Sun.COM 		rc = ddi_log_sysevent(info_dip, DDI_VENDOR_SUNW,
72*9093SRamana.Srikanth@Sun.COM 		    SVE_II_CLASS, component, attr_list, NULL, DDI_SLEEP);
737836SJohn.Forte@Sun.COM out:
747836SJohn.Forte@Sun.COM 	if (attr_list)
757836SJohn.Forte@Sun.COM 		nvlist_free(attr_list);
767836SJohn.Forte@Sun.COM 
777836SJohn.Forte@Sun.COM 	if (rc != 0) {
78*9093SRamana.Srikanth@Sun.COM 		cmn_err(CE_WARN, "!%s: unable to log sysevent %d:%s and %d",
797836SJohn.Forte@Sun.COM 		    driver_name, errorno, trap_messages, alertlevel);
807836SJohn.Forte@Sun.COM 	}
817836SJohn.Forte@Sun.COM #endif  /* which O/S? */
827836SJohn.Forte@Sun.COM }
83