f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * CDDL HEADER START
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * The contents of this file are subject to the terms of the
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * Common Development and Distribution License (the "License").
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * You may not use this file except in compliance with the License.
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * See the License for the specific language governing permissions
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * and limitations under the License.
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * When distributing Covered Code, include this CDDL HEADER in each
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * If applicable, add the following below this CDDL HEADER, with the
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * fields enclosed by brackets "[]" replaced with your own identifying
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * information: Portions Copyright [yyyy] [name of copyright owner]
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae * CDDL HEADER END
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter#define XMLTOPOFILE "/var/run/fab-xlate-topo.xml"
4df55fde49134f9735f84011f23a767c75e393c7Janie Lufmd_xprt_t *fab_fmd_xprt; /* FMD transport layer handle */
4df55fde49134f9735f84011f23a767c75e393c7Janie Lu/* Static FM Topo XML Format and XML XPath Context */
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carterstatic pthread_mutex_t fab_lock = PTHREAD_MUTEX_INITIALIZER;
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter /* Open the temporary file with proper ownership */
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter if ((unlink(XMLTOPOFILE) == -1) && (errno != ENOENT)) {
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter fmd_hdl_debug(hdl, "Failed to remove XML topo file\n");
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter fd = open(XMLTOPOFILE, O_RDWR | O_CREAT | O_EXCL, 0600);
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter fmd_hdl_debug(hdl, "Failed to create XML topo file\n");
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter /* Associate a stream with the temporary file */
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter fmd_hdl_debug(hdl, "Failed to open XML topo file\n");
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter /* Hold topology */
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae if ((thp = fmd_hdl_topo_hold(hdl, TOPO_VERSION)) == NULL) {
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter /* Print topology to XML file */
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae if (topo_xml_print(thp, fp, FM_FMRI_SCHEME_HC, &err) < 0) {
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter /* Release topology */
6bc688af4fb132e30e3dcc0243a24d232b5a3ebaScott M. Carter /* Reload topology from XML file */
b344f6b3aaff135e766e22b3d18489fe22a74198gongtian zhao - Sun Microsystems - Beijing China fab_set_fake_rp(hdl);
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae/*ARGSUSED*/
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnaefab_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class)
4df55fde49134f9735f84011f23a767c75e393c7Janie Lu if (nvlist_dup(nvl, &new_nvl, NV_UNIQUE_NAME) != 0) {
4df55fde49134f9735f84011f23a767c75e393c7Janie Lu if (fmd_nvl_class_match(hdl, new_nvl, "ereport.io.pci.fabric")) {
4df55fde49134f9735f84011f23a767c75e393c7Janie Lu "ereport.io.pciex.rc.epkt")) {
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae/* ARGSUSED */
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae if (fmd_hdl_register(hdl, FMD_API_VERSION, &fmd_info) != 0)
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae /* Init libxml */
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae fab_fmd_xprt = fmd_xprt_open(hdl, FMD_XPRT_RDONLY, NULL, NULL);
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae /* Fini xpath */
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae /* Free xml document */
f41150baf74bdaf964ddfe42d865d3c2380b3623krishnae /* Fini libxml */