fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Remove these 5 when this source can compile with sunddi.h */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ESC_DDI_INITIATOR_REGISTER "ESC_ddi_initiator_register"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ESC_DDI_INITIATOR_UNREGISTER "ESC_ddi_initiator_unregister"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()", "- enter");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_INVALID_ID"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_OBJECT_NOT_FOUND"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_ID_OBSOLETE"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_OBJECT_NOT_FOUND"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_ACCESS_SYMMETRIC"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_INVALID_PARAMETER"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_PATH_UNAVAILABLE"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_PATH_NONOPERATIONAL"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno=MP_DRVR_IDS_NOT_ASSOCIATED"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_INVALID_PARAMETER"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " received mp_errno="
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "MP_DRVR_ILLEGAL_ACCESS_STATE_REQUEST"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " from driver call.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " returning MP_STATUS_INVALID_PARAMETER"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " to caller.");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " - received (unsupported) mp_errno=%d from"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda " - returning MP_STATUS_FAILED to caller.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "getStatus4ErrorCode()", "- exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "requested size is less than 1");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "no memory for pOidList");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " - error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "createOidList()",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- exit(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Calls the client callback function, if one is registered */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(subClassName, sysevent_get_subclass_name(ev), 256);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got a change event");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (strncmp(subClassName, ESC_SUN_MP_PLUGIN_CHANGE, 255)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda } else if (strncmp(subClassName, ESC_SUN_MP_LU_CHANGE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_PATH_CHANGE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_INIT_PORT_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TPG_CHANGE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TARGET_PORT_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_DEV_PROD_CHANGE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (strstr(subClassName, "initiator_register"))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got a visibility"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " add event");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (strncmp(subClassName, ESC_SUN_MP_LU_ADD, 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_PATH_ADD, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_DDI_INITIATOR_REGISTER,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 244) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TPG_ADD,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TARGET_PORT_ADD,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_DEV_PROD_ADD, 255)
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda (strstr(subClassName, "initiator_unregister"))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got a visibility"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " remove event");
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda if (strncmp(subClassName, ESC_SUN_MP_LU_REMOVE, 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_PATH_REMOVE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_DDI_INITIATOR_UNREGISTER,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TPG_REMOVE, 255)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_TARGET_PORT_REMOVE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(subClassName, ESC_SUN_MP_DEV_PROD_REMOVE,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda 255) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- got an unsupported event");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "notifyClient()", "- index is less than zero");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == g_Visibility_Callback_List[index].pClientFn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- no visibility change callback to notify");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NULL == g_Property_Callback_List[index].pClientFn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- no property change callback to notify");
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event (PHCI_INSTANCE) has [%d] elements",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event (PHCI_DRIVER_MAJOR) has [%d] elements",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) nvlist_lookup_uint64_array(attr_list, OIDLIST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event has [%d] elements",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < nelem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- event [%d] = %llx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- unable to create MP_OID_LIST");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < nelem; i++) {
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "oidList->oids[%d].objectType"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "oidList->oids[%d].ownerId"
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda "oidList->oids[%d].objectSequenceNumber"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Event handler called by system */
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 /* Notify client if it cares */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Registers the plugin to the sysevent framework */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_SysEventHandle = sysevent_bind_handle(sysevent_handler);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- sysevent_bind_handle() failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- error exit");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sysevent_subscribe_event(g_SysEventHandle, EC_SUN_MP,
17d7121191d7d90045353185656b2128127d2178Jiri Svoboda subclass_list, sizeof (subclass_list) / sizeof (subclass_list[0]))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "- sysevent_subscribe_event() failed for subclass_list");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- error exit");
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 "- sysevent_subscribe_event() failed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "for init_port_subclass_list");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log(LOG_INFO, "init_sysevents()", "- error exit");