fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "mp_utils.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef OIDLIST
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OIDLIST "oid"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Remove these 5 when this source can compile with sunddi.h */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef EC_DDI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define EC_DDI "EC_ddi"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef ESC_DDI_INITIATOR_REGISTER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ESC_DDI_INITIATOR_REGISTER "ESC_ddi_initiator_register"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef ESC_DDI_INITIATOR_UNREGISTER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ESC_DDI_INITIATOR_UNREGISTER "ESC_ddi_initiator_unregister"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef DDI_DRIVER_MAJOR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DDI_DRIVER_MAJOR "ddi.major"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef DDI_INSTANCE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DDI_INSTANCE "ddi.instance"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VISA_CHANGE 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PROP_CHANGE 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetStatus4ErrorCode(int driverError)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS mpStatus = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()", "- enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (driverError) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MP_DRVR_INVALID_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_INVALID_ID"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_OBJECT_NOT_FOUND"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_OBJECT_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MP_DRVR_ID_OBSOLETE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_ID_OBSOLETE"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_OBJECT_NOT_FOUND"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_OBJECT_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MP_DRVR_ACCESS_SYMMETRIC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_ACCESS_SYMMETRIC"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_INVALID_PARAMETER"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MP_DRVR_PATH_UNAVAILABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_PATH_UNAVAILABLE"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_PATH_NONOPERATIONAL"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_PATH_NONOPERATIONAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MP_DRVR_IDS_NOT_ASSOCIATED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_IDS_NOT_ASSOCIATED"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_INVALID_PARAMETER"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MP_DRVR_ILLEGAL_ACCESS_STATE_REQUEST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno="
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "MP_DRVR_ILLEGAL_ACCESS_STATE_REQUEST"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_INVALID_PARAMETER"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_ACCESS_STATE_INVALID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " - received (unsupported) mp_errno=%d from"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " driver call.", driverError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " - returning MP_STATUS_FAILED to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mpStatus = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()", "- exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (mpStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_OID_LIST
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte*createOidList(int size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST *pOidList = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "createOidList()", "- enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (size < 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "createOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "requested size is less than 1");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "createOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pOidList = (MP_OID_LIST*)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (MP_OID_LIST) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((size - 1) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (MP_OID)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == pOidList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "createOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "no memory for pOidList");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "createOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "createOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- exit(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (pOidList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Calls the client callback function, if one is registered */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortenotifyClient(sysevent_t *ev)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_t *attr_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t *val = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t *instance = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t *major = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int valAllocated = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t nelem = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int eventType = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int index = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pCallerData = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char subClassName[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_BOOL becomingVisible = MP_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST *oidList = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(subClassName, sysevent_get_subclass_name(ev), 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(subClassName, "change")) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventType = PROP_CHANGE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got a change event");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", ": [%s]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subClassName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (strncmp(subClassName, ESC_SUN_MP_PLUGIN_CHANGE, 255)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda == 0) {
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda index = MP_OBJECT_TYPE_PLUGIN;
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda } else if (strncmp(subClassName, ESC_SUN_MP_LU_CHANGE, 255)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_MULTIPATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_PATH_CHANGE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_PATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_INIT_PORT_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_INITIATOR_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TPG_CHANGE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_TARGET_PORT_GROUP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TARGET_PORT_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_TARGET_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_DEV_PROD_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_DEVICE_PRODUCT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((strstr(subClassName, "add")) ||
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (strstr(subClassName, "initiator_register"))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventType = VISA_CHANGE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte becomingVisible = MP_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got a visibility"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " add event");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", ": [%s]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subClassName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (strncmp(subClassName, ESC_SUN_MP_LU_ADD, 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_MULTIPATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_PATH_ADD, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_PATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_DDI_INITIATOR_REGISTER,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 244) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_INITIATOR_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TPG_ADD,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_TARGET_PORT_GROUP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TARGET_PORT_ADD,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_TARGET_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_DEV_PROD_ADD, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_DEVICE_PRODUCT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((strstr(subClassName, "remove")) ||
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (strstr(subClassName, "initiator_unregister"))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventType = VISA_CHANGE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte becomingVisible = MP_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got a visibility"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " remove event");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", ": [%s]",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subClassName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (strncmp(subClassName, ESC_SUN_MP_LU_REMOVE, 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_MULTIPATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_PATH_REMOVE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_PATH_LU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_DDI_INITIATOR_UNREGISTER,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_INITIATOR_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TPG_REMOVE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_TARGET_PORT_GROUP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TARGET_PORT_REMOVE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_TARGET_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_DEV_PROD_REMOVE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = MP_OBJECT_TYPE_DEVICE_PRODUCT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got an unsupported event");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- index is less than zero");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (eventType == VISA_CHANGE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&g_visa_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == g_Visibility_Callback_List[index].pClientFn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- no visibility change callback to notify");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&g_visa_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&g_visa_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (eventType == PROP_CHANGE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&g_prop_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == g_Property_Callback_List[index].pClientFn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- no property change callback to notify");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (void) pthread_mutex_unlock(&g_prop_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda return;
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (void) pthread_mutex_unlock(&g_prop_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sysevent_get_attr_list(ev, &attr_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL != attr_list) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((VISA_CHANGE == eventType) &&
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (MP_OBJECT_TYPE_PLUGIN == index)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda val = (uint64_t *)malloc(sizeof (uint64_t));
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda valAllocated = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda /*
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * We have no well-defined way to determine our OSN.
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * Currently the common library uses 0 as OSN for every
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * plugin, so just use 0. If the OSN assigned by the
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * common library changed, this code would have to be
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * updated.
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda */
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda *val = 0;
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda nelem = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((VISA_CHANGE == eventType) &&
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (MP_OBJECT_TYPE_INITIATOR_PORT == index)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) nvlist_lookup_int32_array(attr_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_INSTANCE, &instance, &nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event (PHCI_INSTANCE) has [%d] elements",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) nvlist_lookup_int32_array(attr_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DRIVER_MAJOR, &major, &nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event (PHCI_DRIVER_MAJOR) has [%d] elements",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((NULL != instance) & (NULL != major)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = (uint64_t *)malloc(sizeof (uint64_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte valAllocated = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
0c034175550709323575bc82b80a835256239e86Jiri Svoboda *val = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *val = MP_STORE_INST_TO_ID(*instance, *val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *val = MP_STORE_MAJOR_TO_ID(*major, *val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nelem = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nelem = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) nvlist_lookup_uint64_array(attr_list, OIDLIST,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda &val, &nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event has [%d] elements",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nelem > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < nelem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event [%d] = %llx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i, val[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oidList = createOidList(nelem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == oidList) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- unable to create MP_OID_LIST");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(attr_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oidList->oidCount = nelem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < nelem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oidList->oids[i].objectType = index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oidList->oids[i].ownerId = g_pluginOwnerID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oidList->oids[i].objectSequenceNumber = val[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (valAllocated) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < oidList->oidCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "oidList->oids[%d].objectType"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " = %d",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda i, oidList->oids[i].objectType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "oidList->oids[%d].ownerId"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " = %d",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda i, oidList->oids[i].ownerId);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "oidList->oids[%d].objectSequenceNumber"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " = %llx",
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda i, oidList->oids[i].objectSequenceNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (eventType == PROP_CHANGE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&g_prop_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pCallerData = g_Property_Callback_List[index].
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda pCallerData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (g_Property_Callback_List[index].pClientFn)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (oidList, pCallerData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&g_prop_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventType == VISA_CHANGE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&g_visa_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pCallerData = g_Visibility_Callback_List[index].
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda pCallerData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (g_Visibility_Callback_List[index].pClientFn)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (becomingVisible, oidList, pCallerData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&g_visa_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(attr_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Event handler called by system */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesysevent_handler(sysevent_t *ev)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "sysevent_handler()", "- enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Is the event one of ours? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strncmp(EC_SUN_MP, sysevent_get_class_name(ev), 9) != 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp(EC_DDI, sysevent_get_class_name(ev), 6) != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Notify client if it cares */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notifyClient(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "sysevent_handler()", "- exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Registers the plugin to the sysevent framework */
17d7121191d7d90045353185656b2128127d2178Jiri SvobodaMP_STATUS
17d7121191d7d90045353185656b2128127d2178Jiri Svobodainit_sysevents(void) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *subclass_list[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda ESC_SUN_MP_PLUGIN_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_LU_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda ESC_SUN_MP_LU_ADD,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda ESC_SUN_MP_LU_REMOVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_PATH_CHANGE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_PATH_ADD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_PATH_REMOVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_INIT_PORT_CHANGE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_TPG_CHANGE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_TPG_ADD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_TPG_REMOVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_TARGET_PORT_CHANGE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_TARGET_PORT_ADD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_TARGET_PORT_REMOVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_DEV_PROD_CHANGE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_DEV_PROD_ADD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_SUN_MP_DEV_PROD_REMOVE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *init_port_subclass_list[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_DDI_INITIATOR_REGISTER,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ESC_DDI_INITIATOR_UNREGISTER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- enter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_SysEventHandle = sysevent_bind_handle(sysevent_handler);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_SysEventHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- sysevent_bind_handle() failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sysevent_subscribe_event(g_SysEventHandle, EC_SUN_MP,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda subclass_list, sizeof (subclass_list) / sizeof (subclass_list[0]))
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- sysevent_subscribe_event() failed for subclass_list");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sysevent_unbind_handle(g_SysEventHandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sysevent_subscribe_event(g_SysEventHandle, EC_DDI,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda init_port_subclass_list, sizeof (init_port_subclass_list) /
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda sizeof (init_port_subclass_list[0])) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- sysevent_subscribe_event() failed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "for init_port_subclass_list");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sysevent_unbind_handle(g_SysEventHandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}