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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusing namespace std;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFCSyseventBridge* FCSyseventBridge::_instance = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFCSyseventBridge* FCSyseventBridge::getInstance() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterAddEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterAddEventListeners.insert(adapterAddEventListeners.begin(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterEventListener *listener, HBA *hba) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterEventListeners.insert(adapterEventListeners.begin(), listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterPortEventListener *listener,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterPortEventListeners.insert(adapterPortEventListeners.begin(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterDeviceEventListener *listener,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterDeviceEventListeners.insert(adapterDeviceEventListeners.begin(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(TargetEventListener *listener,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAPort *port, uint64_t targetWWN, bool filter) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetEventListeners.insert(targetEventListeners.begin(), listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterAddEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterAddEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterAddEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterPortEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterDeviceEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterDeviceEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterDeviceEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterDeviceEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(TargetEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<TargetEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sysevent_get_attr_list(ev, &list) || list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventVendor = sysevent_get_vendor_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventPublisher = sysevent_get_pub_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventSubClass = sysevent_get_subclass_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Now that we know what type of event it is, handle it accordingly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // All events of this class type have instance and port-wwn for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // the HBA port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_uint32(list, (char *)"instance",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no instance field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_byte_array(list, (char *)"port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no port-wwn field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Now deal with the specific details of each subclass type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_online") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_device_online") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterDeviceEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterDeviceEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterDeviceEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_device_offline") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterDeviceEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterDeviceEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterDeviceEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_rscn") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RSCNs are a little tricky. There can be multiple
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * affected page properties, each numbered. To make sure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we get them all, we loop through all properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the nvlist and if their name begins with "affected_page_"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then we send an event for them.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "corrupt affected_page field");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_target_add") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_byte_array(list, (char *)"target-port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no target-port-wwn field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_target_remove") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_byte_array(list, (char *)"target-port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no target-port-wwn field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<TargetEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_attach") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterAddEvent event(wwnConversion(rawPortWWN));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterAddEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterAddEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_detach") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Technically, we should probably try to coalesce
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // all detach events for the same multi-ported adapter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // and only send one event to the client, but for now,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // we'll just blindly send duplicates.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unrecognized subclass \"%s\": Ignoring event",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // This should not happen, as we only asked for specific classes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unrecognized class \"%s\": Ignoring event",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCSyseventBridge::validateRegistration");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to bind sysevent handle.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_attach",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_detach",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_offline",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_online",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_rscn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_target_add",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_target_remove",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_device_online",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_device_offline"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to subscribe to sun_fc events.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Remove subscription
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } // Else do nothing