1 /*
   2  * CDDL HEADER START
   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #include <sys/ddi.h>
  27 #include <sys/sunddi.h>
  28 
  29 #ifdef DS_DDICT
  30 #include "../contract.h"
  31 #endif
  32 
  33 #define SVE_STE_CLASS   "SVE_STE"
  34 #define SVE_II_CLASS    "SVE_II"
  35 #define SVE_CACHE_CLASS "SVE_CACHE"
  36 
  37 void
  38 nsc_do_sysevent(char *driver_name, char *trap_messages, int errorno,
  39         int alertlevel, char *component, dev_info_t *info_dip)
  40 {
  41 #if !defined(DS_DDICT) && !defined(_SunOS_5_6) && \
  42         !defined(_SunOS_5_7) && !defined(_SunOS_5_8)
  43 
  44         nvlist_t *attr_list;
  45         int rc;
  46 
  47         attr_list = NULL;
  48         rc = nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE, KM_SLEEP);
  49         if (rc != 0) {
  50                 goto out;
  51         }
  52         rc = nvlist_add_int32(attr_list, "alertlevel", alertlevel);
  53         if (rc != 0) {
  54                 goto out;
  55         }
  56         rc = nvlist_add_string(attr_list, "messagevalue", trap_messages);
  57         if (rc != 0) {
  58                 goto out;
  59         }
  60         rc = nvlist_add_int32(attr_list, "errorno", errorno);
  61         if (rc != 0) {
  62                 goto out;
  63         }
  64         if (strcmp(driver_name, "sdbc") == 0)
  65                 rc = ddi_log_sysevent(info_dip, DDI_VENDOR_SUNW,
  66                     SVE_CACHE_CLASS, component, attr_list, NULL, DDI_SLEEP);
  67         else if (strcmp(driver_name, "ste") == 0)
  68                 rc = ddi_log_sysevent(info_dip, DDI_VENDOR_SUNW,
  69                     SVE_STE_CLASS, component, attr_list, NULL, DDI_SLEEP);
  70         else if (strcmp(driver_name, "ii") == 0)
  71                 rc = ddi_log_sysevent(info_dip, DDI_VENDOR_SUNW,
  72                     SVE_II_CLASS, component, attr_list, NULL, DDI_SLEEP);
  73 out:
  74         nvlist_free(attr_list);
  75 
  76         if (rc != 0) {
  77                 cmn_err(CE_WARN, "!%s: unable to log sysevent %d:%s and %d",
  78                     driver_name, errorno, trap_messages, alertlevel);
  79         }
  80 #endif  /* which O/S? */
  81 }